<script setup>
import emitter from '@/untils/bus';


emitter.on('sendDataTo1',data=>{
    message.value = data.msg
})

function click(){
    emitter.emit('sendDataTo1',{msg:"来自组件2的信息"})
}

</script>

<template>
    <div>
        <h2>组件2</h2>
        <el-button @click="click">给组件1传递数据</el-button>
    </div>
</template>